package com.gitee.xmhzzz.device.service;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class DeviceServiceFastAutoGenerator {
    public static void main(String[] args) {
        // =                          jdbc:mysql://localhost:3306/mydb
        FastAutoGenerator.create("jjdbc:mysql://192.168.101.5:33016/dev_pirate", "root", "yipule123@")
                .globalConfig(builder -> {
                    builder.author("wzq") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .outputDir("micro-device-service\\src\\main\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.gitee.xmhzzz.device.service")// 设置父包名
                            .entity("dao.entity")
                            .mapper("dao.mapper")
                            .controller("controller")
                            .service("service")
                            .serviceImpl("service.impl")
                            .pathInfo(Collections.singletonMap(OutputFile.xml,"micro-device-service\\src\\main\\resources\\mapper")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("t_device_base_info") // 设置需要生成的表名
                            .addTablePrefix("t_"); // 设置过滤表前缀
                })
                .injectionConfig(builder -> {
                    builder.beforeOutputFile((tableInfo, objectMap)->{

                    });
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();


    }
}
